home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
clang
/
dtk_demo.zip
/
DATEFORM.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-12
|
3KB
|
151 lines
/* DATEFORM.C
* last mod.: 10-AUG-91
*/
/* this displays a given date 54 times
* using different date format parameters;
* in a few cases different parameters produce
* the same result;
* output can be redirected to printer or disk file
*/
#include <STDIO.H>
#include <STDLIB.H>
#include <CONIO.H>
#include <STRING.H>
/*#include <L_FILE.H>*/
#include <L_MISC.H>
#include <L_DATE.H>
#include <L_STR.H>
char *usage = "\nUse DATEFORM month day year\n";
char *prompt = "Press a key ... ";
char date_str[64];
Date dt;
Date_format df;
int n=0;
char backspaces[20];
void main(int argc, char *argv[]);
void display_dates(void);
void display_date(void);
/*-----------------------------*/
void main(int argc, char *argv[])
{
if ( argc < 4 )
{
printf(usage);
exit(0);
}
dt.month = atoi(argv[1]);
dt.day = atoi(argv[2]);
dt.year = atol(argv[3]);
if ( !date_valid(&dt) )
{
printf("\nInvalid date.\n");
exit(1);
}
string(backspaces,'\b',strlen(prompt));
set_date_format_default(&df);
for ( df.short_year=TRUE; df.short_year>=FALSE; df.short_year-- )
{
for ( df.justify=FALSE; df.justify<=TRUE; df.justify++ )
{
if ( !df.justify )
{
for ( df.suffix=FALSE; df.suffix<=TRUE; df.suffix++ )
display_dates();
}
else
{
df.suffix = FALSE;
display_dates();
}
}
}
}
/*--------------------*/
void display_dates(void)
{
df.full_month_name = FALSE;
df.short_month_name = FALSE;
df.full_day_name = FALSE;
df.short_day_name = FALSE;
display_date();
df.full_month_name = FALSE;
df.short_month_name = FALSE;
df.full_day_name = FALSE;
df.short_day_name = TRUE;
display_date();
df.full_month_name = FALSE;
df.short_month_name = FALSE;
df.full_day_name = TRUE;
df.short_day_name = FALSE;
display_date();
df.full_month_name = FALSE;
df.short_month_name = TRUE;
df.full_day_name = FALSE;
df.short_day_name = FALSE;
display_date();
df.full_month_name = FALSE;
df.short_month_name = TRUE;
df.full_day_name = FALSE;
df.short_day_name = TRUE;
display_date();
df.full_month_name = FALSE;
df.short_month_name = TRUE;
df.full_day_name = TRUE;
df.short_day_name = FALSE;
display_date();
df.full_month_name = TRUE;
df.short_month_name = FALSE;
df.full_day_name = FALSE;
df.short_day_name = FALSE;
display_date();
df.full_month_name = TRUE;
df.short_month_name = FALSE;
df.full_day_name = FALSE;
df.short_day_name = TRUE;
display_date();
df.full_month_name = TRUE;
df.short_month_name = FALSE;
df.full_day_name = TRUE;
df.short_day_name = FALSE;
display_date();
}
/*-------------------*/
void display_date(void)
{
date_to_str(&dt,&df,date_str);
pad_on_right(date_str,' ',39);
printf("%s",date_str);
if ( ++n%2 )
putchar(' ');
else
putchar('\n');
if ( !output_redirected() )
{
if ( n == 46 )
{
cputs(prompt);
getch();
cputs(backspaces);
}
}
}